<html>
<head><meta charset="utf-8"><title>Structural match marker traits · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html">Structural match marker traits</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192927648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/192927648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#192927648">(Apr 04 2020 at 21:22)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I see you are working on to refactor the support for consts in patterns. I left a comment on your PR that adds some <code>StructuralEq</code> impls. The weirdness around bounds is explicitly documented <a href="https://doc.rust-lang.org/std/marker/trait.StructuralEq.html" title="https://doc.rust-lang.org/std/marker/trait.StructuralEq.html">in the trait docs</a>. Basically we have to use a type visitor to recurse through all the members of a type in question to determine whether it is "always" structurally matchable (e.g., <code>usize</code>, <code>(usize, usize)</code>, <code>enum X { A(uszie), B(usize) }</code>) or only "sometimes" structurally matchable (e.g. <code>Option&lt;T&gt;</code>). For the sometimes types, we will do structural qualification like we do for <code>NeedsDrop</code> and <code>HasMutInterior</code>.</p>



<a name="193014142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014142">(Apr 06 2020 at 09:10)</a>:</h4>
<p>we could also add a method to <code>StructuralEq</code> and make miri interpret it for a specific constant</p>



<a name="193014148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014148">(Apr 06 2020 at 09:11)</a>:</h4>
<p>that way we need no visitor :D</p>



<a name="193014167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014167">(Apr 06 2020 at 09:11)</a>:</h4>
<p>(but we need a hack that allows us to define associated const functions)</p>



<a name="193014185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014185">(Apr 06 2020 at 09:11)</a>:</h4>
<p>oh... maybe we can do it with an assoc const?</p>



<a name="193014191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014191">(Apr 06 2020 at 09:11)</a>:</h4>
<p>ah no</p>



<a name="193014197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014197">(Apr 06 2020 at 09:11)</a>:</h4>
<p>we need the value as input</p>



<a name="193014784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014784">(Apr 06 2020 at 09:17)</a>:</h4>
<p>also that example in the docs is weird. I don't get how function pointers can be StructuralEq at all</p>



<a name="193014803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193014803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193014803">(Apr 06 2020 at 09:17)</a>:</h4>
<p>function pointers to the same function can be different if they were created in different crates</p>



<a name="193032424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032424">(Apr 06 2020 at 12:19)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> wasn't there a discussion with... you and <span class="user-mention" data-user-id="121053">@varkor</span>, maybe? where we decided const generics + structural eq has really terrible edge cases around pointer equality?</p>



<a name="193032536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032536">(Apr 06 2020 at 12:20)</a>:</h4>
<p>all builtin types have implicit <code>StructuralEq</code> instead of whitelisting the ones that make sense :(</p>



<a name="193032672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032672">(Apr 06 2020 at 12:22)</a>:</h4>
<p>e.g. <code>==</code>/<code>!=</code> on the <code>ConstValue</code> should be sound to rely on in pattern-matching</p>



<a name="193032718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032718">(Apr 06 2020 at 12:22)</a>:</h4>
<p>for leaves, references being the only indirection traversed automatically <em>before</em> that</p>



<a name="193032750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032750">(Apr 06 2020 at 12:22)</a>:</h4>
<p>seems unsound to have any kind of <em>address</em> in this system</p>



<a name="193032780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032780">(Apr 06 2020 at 12:23)</a>:</h4>
<p>the only non-ZST leaves should be pure integers</p>



<a name="193032794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032794">(Apr 06 2020 at 12:23)</a>:</h4>
<p>like <code>&amp;str</code> would compare the actual UTF-8 bytes which are integers</p>



<a name="193032895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032895">(Apr 06 2020 at 12:24)</a>:</h4>
<p>so I guess both pattern-matching and <code>const</code> generics need us to ban code that compiles on stable :/</p>



<a name="193032900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032900">(Apr 06 2020 at 12:24)</a>:</h4>
<p>is there an issue about this?</p>



<a name="193032995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193032995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193032995">(Apr 06 2020 at 12:24)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span> who might not have seen previous discussions we had (elsewhere? Discord maybe? I forget)</p>



<a name="193033022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033022">(Apr 06 2020 at 12:25)</a>:</h4>
<p>but also those previous discussions didn't focus on how pattern-matching may interact with non-integers</p>



<a name="193033126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033126">(Apr 06 2020 at 12:26)</a>:</h4>
<p>you can't traverse references automatically, since you can manually implement <code>PartialEq</code> for <code>&amp;T</code> where <code>T: !StructPartialEq</code></p>



<a name="193033191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033191">(Apr 06 2020 at 12:26)</a>:</h4>
<p>I'm talking about <code>StructuralEq</code> references</p>



<a name="193033196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033196">(Apr 06 2020 at 12:26)</a>:</h4>
<p>any others are just banned</p>



<a name="193033211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033211">(Apr 06 2020 at 12:27)</a>:</h4>
<p>i thought others just default to <code>==</code>?</p>



<a name="193033232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033232">(Apr 06 2020 at 12:27)</a>:</h4>
<p>for backcompat</p>



<a name="193033264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033264">(Apr 06 2020 at 12:27)</a>:</h4>
<p>and don't get any exhaustiveness or other fancy checks</p>



<a name="193033265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033265">(Apr 06 2020 at 12:27)</a>:</h4>
<p>sure but that's not relevant to soundness and <code>const</code> generics</p>



<a name="193033297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033297">(Apr 06 2020 at 12:27)</a>:</h4>
<p><em>because</em> they don't factor into exhaustiveness and whatnot</p>



<a name="193033359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033359">(Apr 06 2020 at 12:28)</a>:</h4>
<p>and <code>const</code> generics would just ban them</p>



<a name="193033371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033371">(Apr 06 2020 at 12:28)</a>:</h4>
<p>oh, you mean the breaking change is that they are relevant for exhaustivness right now?</p>



<a name="193033380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033380">(Apr 06 2020 at 12:28)</a>:</h4>
<p>the problem is <code>StructuralEq</code> raw/<code>fn</code> <em>pointers</em></p>



<a name="193033387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033387">(Apr 06 2020 at 12:28)</a>:</h4>
<p>compared by <em>abstract address</em></p>



<a name="193033400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033400">(Apr 06 2020 at 12:28)</a>:</h4>
<p>yea</p>



<a name="193033435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033435">(Apr 06 2020 at 12:29)</a>:</h4>
<p>references are fine <em>because</em> they're like a <code>(T,)</code> to the structural eq property</p>



<a name="193033463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033463">(Apr 06 2020 at 12:29)</a>:</h4>
<p>but any other kind of indirection is not</p>



<a name="193033481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033481">(Apr 06 2020 at 12:29)</a>:</h4>
<p>boxes?</p>



<a name="193033520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033520">(Apr 06 2020 at 12:29)</a>:</h4>
<p>not a thing AFAIK, you have to use <code>box</code> patterns</p>



<a name="193033542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033542">(Apr 06 2020 at 12:30)</a>:</h4>
<p>yes</p>



<a name="193033601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033601">(Apr 06 2020 at 12:30)</a>:</h4>
<p>so unstable -&gt; let's ignore</p>



<a name="193033610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033610">(Apr 06 2020 at 12:30)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> if there isn't an issue already about non-integral leaves, can you open one? I'm already doing several things at once</p>



<a name="193033631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033631">(Apr 06 2020 at 12:30)</a>:</h4>
<p>or maybe I should, it's not clear I got my point across Q_Q</p>



<a name="193033639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033639">(Apr 06 2020 at 12:30)</a>:</h4>
<p>you didn't</p>



<a name="193033646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033646">(Apr 06 2020 at 12:30)</a>:</h4>
<p>and I don't have the time to invent examples</p>



<a name="193033683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033683">(Apr 06 2020 at 12:30)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> so, <code>!StructuralEq</code> types are sound by definition since <em>we don't trust them</em></p>



<a name="193033736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033736">(Apr 06 2020 at 12:31)</a>:</h4>
<p>but there are <em>untrustworthy primitives</em> that nevertheless we implemented <code>StructuralEq</code> for</p>



<a name="193033758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033758">(Apr 06 2020 at 12:31)</a>:</h4>
<p>because we <em>assumed</em> that only custom <code>impl</code>s could be untrustworthy</p>



<a name="193033770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033770">(Apr 06 2020 at 12:31)</a>:</h4>
<p>but that's just wrong</p>



<a name="193033845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033845">(Apr 06 2020 at 12:32)</a>:</h4>
<p>but what if we just stopped doing that? would we break anything? you can't exhaustively match function pointers or even raw pointers for that matter</p>



<a name="193033876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033876">(Apr 06 2020 at 12:32)</a>:</h4>
<p>okay yeah I'm suggesting to try breaking them</p>



<a name="193033894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033894">(Apr 06 2020 at 12:32)</a>:</h4>
<p>we'd stop detecting unreachable arms, but <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="193033896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033896">(Apr 06 2020 at 12:32)</a>:</h4>
<p>and the hard part would be finding an example showing they're unsound</p>



<a name="193033941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193033941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193033941">(Apr 06 2020 at 12:32)</a>:</h4>
<p>ok, with that info I can work, I'll play a bit and open an issue</p>



<a name="193034010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034010">(Apr 06 2020 at 12:33)</a>:</h4>
<p>maybe we can use <code>const</code> generics to craft an example? but idk if it even enforces <code>StructuralEq</code> yet</p>



<a name="193034202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034202">(Apr 06 2020 at 12:34)</a>:</h4>
<p>it doesn't</p>



<a name="193034208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034208">(Apr 06 2020 at 12:34)</a>:</h4>
<p>I guess we can't because the value is never computed at runtime</p>



<a name="193034242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034242">(Apr 06 2020 at 12:35)</a>:</h4>
<p>so it's just <em>weird</em> right now</p>



<a name="193034367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034367">(Apr 06 2020 at 12:36)</a>:</h4>
<p>ah... now I get what <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> is talking about. We can use a constant in pattern matching if its value does not contain any <code>!StructuralEq</code> values</p>



<a name="193034415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034415">(Apr 06 2020 at 12:36)</a>:</h4>
<p>yeah</p>



<a name="193034951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034951">(Apr 06 2020 at 12:41)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b</a></p>



<a name="193034961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193034961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193034961">(Apr 06 2020 at 12:41)</a>:</h4>
<p>this is a fun example</p>



<a name="193035009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193035009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193035009">(Apr 06 2020 at 12:42)</a>:</h4>
<p>compare output from debug vs release</p>



<a name="193035118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193035118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193035118">(Apr 06 2020 at 12:43)</a>:</h4>
<p>it doesn't show anything <em>egregious</em></p>



<a name="193035340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193035340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193035340">(Apr 06 2020 at 12:45)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> and this is what happens if you make <code>fn</code> pointers non-<code>StructuralEq</code> <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=801477c9fcfad4074c0daa3683ff00e3" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=801477c9fcfad4074c0daa3683ff00e3">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=801477c9fcfad4074c0daa3683ff00e3</a></p>



<a name="193035376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193035376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193035376">(Apr 06 2020 at 12:45)</a>:</h4>
<p>doesn't fall back to <code>==</code></p>



<a name="193036505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036505">(Apr 06 2020 at 12:54)</a>:</h4>
<p>but we could avoid any breaking changes by falling back to <code>==</code></p>



<a name="193036587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036587">(Apr 06 2020 at 12:54)</a>:</h4>
<p>eeeeeeeh</p>



<a name="193036623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036623">(Apr 06 2020 at 12:55)</a>:</h4>
<p>you'd first have to figure out why we broke things in the past (e.g. floats) <em>without</em> doing that</p>



<a name="193036657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036657">(Apr 06 2020 at 12:55)</a>:</h4>
<p>I think it's hard to keep things sound when you have nested patterns</p>



<a name="193036684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036684">(Apr 06 2020 at 12:55)</a>:</h4>
<p>probably have to treat it like <code>x if x == CONST</code></p>



<a name="193036702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036702">(Apr 06 2020 at 12:55)</a>:</h4>
<p>but we don't have that today</p>



<a name="193036822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193036822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193036822">(Apr 06 2020 at 12:56)</a>:</h4>
<p>so it'd have to be like <code>ref x</code> that can still fail to match</p>



<a name="193038102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193038102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193038102">(Apr 06 2020 at 13:05)</a>:</h4>
<blockquote>
<p>but idk if it even enforces StructuralEq yet</p>
</blockquote>
<p>const generics do enforce <code>structural_match</code> now</p>



<a name="193038371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193038371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193038371">(Apr 06 2020 at 13:07)</a>:</h4>
<blockquote>
<p>but what if we just stopped doing that? would we break anything?</p>
</blockquote>
<p>we would break using constants of those types in patterns</p>



<a name="193038556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193038556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193038556">(Apr 06 2020 at 13:09)</a>:</h4>
<p>ah, I see that was pointed out above</p>



<a name="193038640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193038640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193038640">(Apr 06 2020 at 13:10)</a>:</h4>
<p>I wonder how much fallout we would get if we just banned pointers <em>without</em> adding a <code>==</code> fallback</p>



<a name="193038698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193038698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193038698">(Apr 06 2020 at 13:10)</a>:</h4>
<p>how many people can really be relying on explicit pointer matching? :/</p>



<a name="193039077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039077">(Apr 06 2020 at 13:13)</a>:</h4>
<p>note that I'm not 100% sure how type-based it can be, I'm talking about pointer <em>values</em>, which could potentially be hidden in integers (I hope not?)</p>



<a name="193039103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039103">(Apr 06 2020 at 13:13)</a>:</h4>
<p>and <code>*mut T</code> with an integer <em>value</em> would be a perfectly fine pattern :P</p>



<a name="193039540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039540">(Apr 06 2020 at 13:16)</a>:</h4>
<p>we are forbidding <code>usize</code> constants from having relocation value</p>



<a name="193039599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039599">(Apr 06 2020 at 13:17)</a>:</h4>
<p>okay so at least that shouldn't cause issues</p>



<a name="193039657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039657">(Apr 06 2020 at 13:17)</a>:</h4>
<p>we surely don't want to make the structural match property depend on <em>values</em>?</p>



<a name="193039678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039678">(Apr 06 2020 at 13:17)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d60d7ca1fd1a804026813a88b3e5fca9" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d60d7ca1fd1a804026813a88b3e5fca9">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=d60d7ca1fd1a804026813a88b3e5fca9</a></p>



<a name="193039749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039749">(Apr 06 2020 at 13:18)</a>:</h4>
<p>we may have to, but I'd prefer not to either</p>



<a name="193039789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039789">(Apr 06 2020 at 13:18)</a>:</h4>
<p>my brain breaks enough with the value based things for <code>UnsafeCell</code></p>



<a name="193039798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039798">(Apr 06 2020 at 13:18)</a>:</h4>
<p>if we can avoid it I'll be happy</p>



<a name="193039924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193039924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193039924">(Apr 06 2020 at 13:19)</a>:</h4>
<p>what's the issue with trying to disable structural match for pointer types and then if users store addresses in other types, that's on them?</p>



<a name="193040030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193040030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193040030">(Apr 06 2020 at 13:20)</a>:</h4>
<p>no it's fine, as long as we ban addresses in other types early</p>



<a name="193040042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193040042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193040042">(Apr 06 2020 at 13:20)</a>:</h4>
<p>we do</p>



<a name="193071646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193071646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193071646">(Apr 06 2020 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I also don't understand why <code>StructuralEq</code> needs to exist after reading its documentation, perhaps <span class="user-mention" data-user-id="116083">@pnkfelix</span> could inform us?</p>



<a name="193071814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193071814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193071814">(Apr 06 2020 at 17:08)</a>:</h4>
<p>I think it's for floats basically. Floats are <code>!StructuralEq</code> but they are <code>StructuralPartialEq</code> because of NaNs</p>



<a name="193071984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193071984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193071984">(Apr 06 2020 at 17:10)</a>:</h4>
<p>The documentation explicitly calls out function pointers not implementing <code>PartialEq</code> and <code>Eq</code>, but I thought they did?</p>



<a name="193072093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072093">(Apr 06 2020 at 17:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071814" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071814">said</a>:</p>
<blockquote>
<p>I think it's for floats basically. Floats are <code>!StructuralEq</code> but they are <code>StructuralPartialEq</code> because of NaNs</p>
</blockquote>
<p>Hm, but then we could just check for <code>Eq</code>. We wouldn't need a separate structural version.</p>



<a name="193072338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072338">(Apr 06 2020 at 17:12)</a>:</h4>
<p>Can't you impl <code>Eq</code> manually for a type that is <code>StructuralPartialEq</code>?</p>



<a name="193072381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072381">(Apr 06 2020 at 17:13)</a>:</h4>
<p>or or is an <code>Eq</code> derive also required for <code>StructuralPartialEq</code>?</p>



<a name="193072388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072388">(Apr 06 2020 at 17:13)</a>:</h4>
<p>In any case, I'll be working on using the <code>Qualif</code> machinery for determining structural match. One of the difficulties I had was that pattern lowering was a bit messy, so I'm very happy to see it get refactored.</p>



<a name="193072462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072462">(Apr 06 2020 at 17:13)</a>:</h4>
<p>Do we really need such a value based analysis?</p>



<a name="193072565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072565">(Apr 06 2020 at 17:14)</a>:</h4>
<p>The goal would be to fix some longstanding bugs where we accidentally allow some non structural match constants in patterns.</p>



<a name="193072598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072598">(Apr 06 2020 at 17:14)</a>:</h4>
<p><code>StructuralPartialEq</code>+<code>StructuralEq</code> is the replacement for <code>#[structural_match]</code></p>



<a name="193072604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072604">(Apr 06 2020 at 17:14)</a>:</h4>
<p>right, but the alternative solution is to just allow them and treat them as opaque</p>



<a name="193072607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072607">(Apr 06 2020 at 17:14)</a>:</h4>
<p>It's not to allow new things</p>



<a name="193072612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072612">(Apr 06 2020 at 17:14)</a>:</h4>
<p>which was too fragile</p>



<a name="193072659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072659">(Apr 06 2020 at 17:15)</a>:</h4>
<p>(and also problematic to have, since it detected <em>two</em> derives at once)</p>



<a name="193072676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072676">(Apr 06 2020 at 17:15)</a>:</h4>
<p>/me goes to look up some issue numbers</p>



<a name="193072712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072712">(Apr 06 2020 at 17:15)</a>:</h4>
<p>the traits are just there to detect a property</p>



<a name="193072724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072724">(Apr 06 2020 at 17:15)</a>:</h4>
<p>i.e. that <code>#[derive(PartialEq, Eq)]</code> was used</p>



<a name="193072773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072773">(Apr 06 2020 at 17:16)</a>:</h4>
<p>each trait is meaningless on its own</p>



<a name="193072894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072894">(Apr 06 2020 at 17:17)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I'm still unclear why we need both a <code>StructuralPartialEq</code> and a <code>StructuralEq</code>. Here's the docs for <code>StructuralEq</code>:</p>
<blockquote>
<p>In a more ideal world, we could check that requirement by just checking that the given type implements both (1.) the StructuralPartialEq trait and (2.) the Eq trait. However, you can have ADTs that do derive(PartialEq, Eq), and be a case that we want the compiler to accept, and yet the constant's type fails to implement Eq.</p>
<p>Namely, a case like this:</p>
</blockquote>
<div class="codehilite"><pre><span></span><span class="cp">#[derive(PartialEq, Eq)]</span><span class="w"></span>
<span class="k">struct</span> <span class="nc">Wrap</span><span class="o">&lt;</span><span class="n">X</span><span class="o">&gt;</span><span class="p">(</span><span class="n">X</span><span class="p">);</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">higher_order</span><span class="p">(</span><span class="n">_</span>: <span class="kp">&amp;</span><span class="p">())</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">const</span><span class="w"> </span><span class="n">CFN</span>: <span class="nc">Wrap</span><span class="o">&lt;</span><span class="k">fn</span><span class="p">(</span><span class="o">&amp;</span><span class="p">())</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Wrap</span><span class="p">(</span><span class="n">higher_order</span><span class="p">);</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="n">CFN</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">CFN</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<blockquote>
<p>(The problem in the above code is that Wrap&lt;fn(&amp;())&gt; does not implement PartialEq, nor Eq, because for&lt;'a&gt; fn(&amp;'a _) does not implement those traits.)</p>
<p>Therefore, we cannot rely on naive check for StructuralPartialEq and mere Eq.</p>
</blockquote>



<a name="193072967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072967">(Apr 06 2020 at 17:18)</a>:</h4>
<p>what</p>



<a name="193072984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193072984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193072984">(Apr 06 2020 at 17:18)</a>:</h4>
<p>the reason for two traits is because that's the only way to do this</p>



<a name="193073032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073032">(Apr 06 2020 at 17:18)</a>:</h4>
<p>am I missing something?</p>



<a name="193073054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073054">(Apr 06 2020 at 17:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071984" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071984">said</a>:</p>
<blockquote>
<p>The documentation explicitly calls out function pointers not implementing <code>PartialEq</code> and <code>Eq</code>, but I thought they did?</p>
</blockquote>
<p><code>for &lt;'a&gt; fn(&amp;'a _)</code> does not, I think...</p>



<a name="193073058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073058">(Apr 06 2020 at 17:19)</a>:</h4>
<p><code>#[derive(PartialEq)]</code> + manual <code>Eq</code> impl is the thing we want to guard against</p>



<a name="193073108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073108">(Apr 06 2020 at 17:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073054" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073054">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="118594">ecstatic-morse</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071984" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193071984">said</a>:</p>
<blockquote>
<p>The documentation explicitly calls out function pointers not implementing <code>PartialEq</code> and <code>Eq</code>, but I thought they did?</p>
</blockquote>
<p><code>for &lt;'a&gt; fn(&amp;'a _)</code> does not, I think...</p>
</blockquote>
<p>can't we "just" fix that? More compiler magic or sth</p>



<a name="193073114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073114">(Apr 06 2020 at 17:19)</a>:</h4>
<p>also I thought all builtin impls were just automatically <code>StructuralEq</code> which is the reason we have the bug where pointers are considered <code>StructuralEq</code></p>



<a name="193073170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073170">(Apr 06 2020 at 17:20)</a>:</h4>
<p>or was that only the case with the old <code>#[structural_match]</code>?</p>



<a name="193073187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073187">(Apr 06 2020 at 17:20)</a>:</h4>
<p>it's all very confusing :D</p>



<a name="193073202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073202">(Apr 06 2020 at 17:20)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/62614" title="https://github.com/rust-lang/rust/issues/62614">#62614</a> is the main one. <a href="https://github.com/rust-lang/rust/issues/65466" title="https://github.com/rust-lang/rust/issues/65466">#65466</a> is related, but I think  a value-based strategy is not necessary  to resolve it.</p>



<a name="193073212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073212">(Apr 06 2020 at 17:20)</a>:</h4>
<p>I haven't found any impls for primitives in libcore</p>



<a name="193073268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073268">(Apr 06 2020 at 17:20)</a>:</h4>
<p>my opinion was that we're missing a whitelist in the compiler: not all primitives should be considered structurally matchable, IMO</p>



<a name="193073303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073303">(Apr 06 2020 at 17:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073058" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073058">said</a>:</p>
<blockquote>
<p><code>#[derive(PartialEq)]</code> + manual <code>Eq</code> impl is the thing we want to guard against</p>
</blockquote>
<p>(or a manual <code>PartialEq</code> and a <code>#[derive(Eq)]</code>, right?)</p>



<a name="193073327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073327">(Apr 06 2020 at 17:21)</a>:</h4>
<p>sure yeah</p>



<a name="193073354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073354">(Apr 06 2020 at 17:21)</a>:</h4>
<p>each trait corresponds to <em>one</em> <code>#[derive(...)]</code></p>



<a name="193073376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073376">(Apr 06 2020 at 17:22)</a>:</h4>
<p>there's two because there's two <code>#[derive(...)]</code>s we need to check the conjunction of</p>



<a name="193073436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073436">(Apr 06 2020 at 17:22)</a>:</h4>
<p>right, because that was the simplest way to handle the injection via <code>derive</code></p>



<a name="193073460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073460">(Apr 06 2020 at 17:22)</a>:</h4>
<p>(s/simplest/only/, if you like)</p>



<a name="193073475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073475">(Apr 06 2020 at 17:22)</a>:</h4>
<p>this used to be done in the implementation of those derives, by injecting<code>#[structural_match]</code> when both were present</p>



<a name="193073504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073504">(Apr 06 2020 at 17:22)</a>:</h4>
<p>but that's not something the proc macro system is meant to support, hence the traits</p>



<a name="193073519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073519">(Apr 06 2020 at 17:22)</a>:</h4>
<p>(or <em>can</em> fully support)</p>



<a name="193073564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073564">(Apr 06 2020 at 17:23)</a>:</h4>
<p>I'm not really sure primites implement <code>StructuralEq</code></p>



<a name="193073581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073581">(Apr 06 2020 at 17:23)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> most primitives are currently handled by a <a href="https://github.com/rust-lang/rust/blob/bd18bc9a4c142100a7230e1fd1cfe6be08214693/src/librustc_trait_selection/traits/structural_match.rs#L140" title="https://github.com/rust-lang/rust/blob/bd18bc9a4c142100a7230e1fd1cfe6be08214693/src/librustc_trait_selection/traits/structural_match.rs#L140"><code>TypeVisitor</code></a>, that's why those impls aren't needed for things to work.</p>



<a name="193073591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073591">(Apr 06 2020 at 17:23)</a>:</h4>
<p>maybe the traits are poorly named</p>



<a name="193073608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073608">(Apr 06 2020 at 17:23)</a>:</h4>
<p>nothing in the <code>type_marked_structural</code> implementation mentions primitives</p>



<a name="193073644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073644">(Apr 06 2020 at 17:24)</a>:</h4>
<p><code>AutoDerivedPartialEq</code> and <code>AutoDerivedEq</code> may have been better</p>



<a name="193073696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073696">(Apr 06 2020 at 17:24)</a>:</h4>
<p>because that's <em>all</em> they are</p>



<a name="193073724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073724">(Apr 06 2020 at 17:24)</a>:</h4>
<p>does anything else manually implement <del>it</del> them?</p>



<a name="193073727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073727">(Apr 06 2020 at 17:24)</a>:</h4>
<p>Err, well I guess just pointers</p>



<a name="193073736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073736">(Apr 06 2020 at 17:24)</a>:</h4>
<p>Hmm</p>



<a name="193073831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073831">(Apr 06 2020 at 17:25)</a>:</h4>
<p>ahh. yea, <code>typed_marked_structural</code> does not recurse</p>



<a name="193073836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073836">(Apr 06 2020 at 17:25)</a>:</h4>
<p>I think maybe the names confused people and led to incorrect changes?</p>



<a name="193073874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073874">(Apr 06 2020 at 17:25)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> because "marked" just means the old <code>#[structural_match]</code> attribute check</p>



<a name="193073887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073887">(Apr 06 2020 at 17:25)</a>:</h4>
<p>yea <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span></p>



<a name="193073902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073902">(Apr 06 2020 at 17:25)</a>:</h4>
<p>it means it's "transparent"</p>



<a name="193073999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193073999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193073999">(Apr 06 2020 at 17:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116083">pnkfelix</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073724" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193073724">said</a>:</p>
<blockquote>
<p>does anything else manually implement <del>it</del> them?</p>
</blockquote>
<p>ah <code>PhantomData</code> does, I think</p>



<a name="193074001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074001">(Apr 06 2020 at 17:26)</a>:</h4>
<p>if the derives also put the requirement on its bounds that would work</p>



<a name="193074055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074055">(Apr 06 2020 at 17:26)</a>:</h4>
<p>that explains why <a href="https://github.com/rust-lang/rust/pull/70759" title="https://github.com/rust-lang/rust/pull/70759">https://github.com/rust-lang/rust/pull/70759</a> doesn't change anything</p>



<a name="193074129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074129">(Apr 06 2020 at 17:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193074001" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193074001">said</a>:</p>
<blockquote>
<p>if the derives also put the requirement on its bounds that would work</p>
</blockquote>
<p>which requirement? <code>StructuralPartialEq</code> and <code>StructuralEq</code>? I think there was a specific reason we didn't do that</p>



<a name="193074246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074246">(Apr 06 2020 at 17:28)</a>:</h4>
<p>the traits <em>are badly named</em></p>



<a name="193074254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074254">(Apr 06 2020 at 17:28)</a>:</h4>
<p>so if we made the derives put bounds on generic parameters <em>and</em> fixed <code>for&lt;'a&gt; fn(&amp;'a T)</code> so it'd implement <code>StructuralPartialEq</code>, then we'd have a recursive <code>type_marked_structural</code></p>



<a name="193074262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074262">(Apr 06 2020 at 17:28)</a>:</h4>
<p>there's no reason to have bounds on them because they're just an attribute</p>



<a name="193074291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074291">(Apr 06 2020 at 17:28)</a>:</h4>
<p>they can't be an attribute because derives can't modify the original item</p>



<a name="193074297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074297">(Apr 06 2020 at 17:28)</a>:</h4>
<p>(AFAIK)</p>



<a name="193074321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074321">(Apr 06 2020 at 17:28)</a>:</h4>
<p>they can't</p>



<a name="193074459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074459">(Apr 06 2020 at 17:30)</a>:</h4>
<p>a hypothetical <code>StructuralMatch</code> would have to require <code>AutoDerivedPartialEq + AutoDerivedEq</code> <em>at every level</em></p>



<a name="193074525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074525">(Apr 06 2020 at 17:30)</a>:</h4>
<p>But what I'm saying the whole time is that it would be nice to have them be a real trait, because then we could a) move a lot of the logic to libcore instead of doing weird things in the compiler and b) we could add a const method that does the logic that <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> is trying to implement as a Qualif</p>



<a name="193074554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074554">(Apr 06 2020 at 17:30)</a>:</h4>
<p>why add a <code>const</code> method?</p>



<a name="193074656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074656">(Apr 06 2020 at 17:31)</a>:</h4>
<p>if you have a <code>const fn value_is_structural_match(&amp;self) -&gt; bool</code> then you could make sure that an <code>Option::None</code> is always <code>structural_match</code></p>



<a name="193074669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074669">(Apr 06 2020 at 17:31)</a>:</h4>
<p>also IIUC the entire thing is value based, but on the HIR?</p>



<a name="193074675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074675">(Apr 06 2020 at 17:31)</a>:</h4>
<p>for the matching logic</p>



<a name="193074676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074676">(Apr 06 2020 at 17:31)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> If you bound on generic parameters, how does <code>const NONE: Option&lt;NonStructuralEqTy&gt; = None</code> get handled.</p>



<a name="193074699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074699">(Apr 06 2020 at 17:31)</a>:</h4>
<p>and the whole point with the qualif stuff is that we move the HIR analysis to MIR</p>



<a name="193074714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074714">(Apr 06 2020 at 17:31)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> ah I highly disapprove of letting the library configure that</p>



<a name="193074717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074717">(Apr 06 2020 at 17:31)</a>:</h4>
<p>yes and I want to move it to const eval and having it defined in source instead of in the compiler</p>



<a name="193074728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074728">(Apr 06 2020 at 17:31)</a>:</h4>
<p>well... it's auto-derived</p>



<a name="193074736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074736">(Apr 06 2020 at 17:31)</a>:</h4>
<p>you don't write this as a user</p>



<a name="193074739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074739">(Apr 06 2020 at 17:31)</a>:</h4>
<p>never, that makes no sense</p>



<a name="193074797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074797">(Apr 06 2020 at 17:32)</a>:</h4>
<p>just like you don't write <code>StructuralEq</code> impls</p>



<a name="193074830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074830">(Apr 06 2020 at 17:32)</a>:</h4>
<p>ok, as a first step we can change <code>StructuralEq</code> to <code>AutoDerivedEq</code></p>



<a name="193074832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074832">(Apr 06 2020 at 17:32)</a>:</h4>
<p>it's trivial to make that correct in the compiler - since we already have this analysis for other purposes</p>



<a name="193074863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074863">(Apr 06 2020 at 17:32)</a>:</h4>
<p>but if you're doing CTFE to find out an answer... that's <em>really</em> scary</p>



<a name="193074873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074873">(Apr 06 2020 at 17:33)</a>:</h4>
<p>I love it</p>



<a name="193074883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074883">(Apr 06 2020 at 17:33)</a>:</h4>
<p>I hate it</p>



<a name="193074891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074891">(Apr 06 2020 at 17:33)</a>:</h4>
<p><span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="193074897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193074897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193074897">(Apr 06 2020 at 17:33)</a>:</h4>
<p>especially since <em>a sound analysis is what const generics need</em></p>



<a name="193075009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075009">(Apr 06 2020 at 17:34)</a>:</h4>
<p>introducing CTFE as an extra step seems wholly unnecessary</p>



<a name="193075055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075055">(Apr 06 2020 at 17:34)</a>:</h4>
<p>the important thing to me is that we start whitelisting primitives and try to remove the pointers from the whitelist</p>



<a name="193075091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075091">(Apr 06 2020 at 17:34)</a>:</h4>
<p>instead of allowing any built-in types by default</p>



<a name="193075106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075106">(Apr 06 2020 at 17:34)</a>:</h4>
<p>ok</p>



<a name="193075321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075321">(Apr 06 2020 at 17:36)</a>:</h4>
<p>still, <a href="https://github.com/rust-lang/rust/pull/70759" title="https://github.com/rust-lang/rust/pull/70759">https://github.com/rust-lang/rust/pull/70759</a> makes sense even if we assume that <code>StructuralEq</code> is called <code>AutoDerivedEq</code>, because we can't autoderive <code>Eq</code> for slice types</p>



<a name="193075335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075335">(Apr 06 2020 at 17:36)</a>:</h4>
<p>slices are built-in</p>



<a name="193075409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075409">(Apr 06 2020 at 17:36)</a>:</h4>
<p>the traits are for <em>literally</em> <code>#[derive(PartialEq, Eq)]</code> <em>written by users</em></p>



<a name="193075488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075488">(Apr 06 2020 at 17:37)</a>:</h4>
<p>I was just thinking that it would make more sense to define these things in libcore instead of in rustc</p>



<a name="193075802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193075802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193075802">(Apr 06 2020 at 17:40)</a>:</h4>
<p>so you prefer a whitelist in rustc over writing things like <code>impl StructuralEq for u8</code> (assuming a new trait <code>StructuralEq</code> in contrast to the soon renamed one that is <code>AutoDerivedEq</code>)</p>



<a name="193076973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193076973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193076973">(Apr 06 2020 at 17:48)</a>:</h4>
<p>specifically I prefer the value check to be in the compiler instead of a <code>const fn</code> method in a trait</p>



<a name="193078626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193078626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193078626">(Apr 06 2020 at 18:00)</a>:</h4>
<p>so IMO priorities:</p>
<ol>
<li>rename the traits</li>
<li>add a whitelist for builtin/primitive types instead of "everything goes"</li>
<li>finish the move of the value-oriented analysis to MIR const-qualif</li>
</ol>



<a name="193079918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193079918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193079918">(Apr 06 2020 at 18:10)</a>:</h4>
<p>^ <span class="user-mention" data-user-id="116083">@pnkfelix</span> I put my opinion on how to make progress on this in here</p>



<a name="193079996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193079996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193079996">(Apr 06 2020 at 18:11)</a>:</h4>
<p>/me needs to grab a snack, low blood sugar after getting dragged into all of this</p>



<a name="193080057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193080057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193080057">(Apr 06 2020 at 18:11)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> also, in case you missed it, the scary bit for <code>const</code> generics (and kind of pattern-matching too) is that we can't trust pointers</p>



<a name="193080183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193080183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193080183">(Apr 06 2020 at 18:12)</a>:</h4>
<p>my example was <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=bd3fca6a9c204a1579448e465461f28b</a> and how it changes between debug and release mode</p>



<a name="193105674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193105674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193105674">(Apr 06 2020 at 21:41)</a>:</h4>
<p>hmm oh dear</p>



<a name="193105829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193105829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193105829">(Apr 06 2020 at 21:42)</a>:</h4>
<p>does this imply we should simply issue a breaking change and disallow matching on <code>fn</code> pointers (and other pointer types in general)? Or is this a compiler bug we might expect to be able to fix?</p>



<a name="193105967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193105967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193105967">(Apr 06 2020 at 21:43)</a>:</h4>
<p>/me is reminded of the debates in the Scheme community about the behavior of <code>eq?</code>/<code>eqv?</code>/<code>equal?</code> on procedure values.</p>



<a name="193105977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193105977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193105977">(Apr 06 2020 at 21:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> the former but we should measure the impact before we think too much about it. I guess I should try to induce this breaking change and we can do a crater check-only run?</p>



<a name="193105998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193105998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193105998">(Apr 06 2020 at 21:43)</a>:</h4>
<p>not 100% sure I can cleanly do it but I can try</p>



<a name="193106012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106012">(Apr 06 2020 at 21:43)</a>:</h4>
<p>Certainly there are test cases in the compiler itself that were relying on being able to match <code>fn</code> pointers</p>



<a name="193106029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106029">(Apr 06 2020 at 21:44)</a>:</h4>
<p>that were based on bugs filed when we broke it</p>



<a name="193106135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106135">(Apr 06 2020 at 21:44)</a>:</h4>
<p>I wasn't too surprised to see <span class="user-mention" data-user-id="124288">@oli</span> note that this could break in the cross-crate case, but I am a little surprised to see it break here</p>



<a name="193106171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106171">(Apr 06 2020 at 21:45)</a>:</h4>
<p>it's due to deduplication instead of duplication</p>



<a name="193106184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106184">(Apr 06 2020 at 21:45)</a>:</h4>
<p>though I shouldn't be, given my experience with compilers doing stuff with duplicating and de-duplicating function definitions</p>



<a name="193106202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106202">(Apr 06 2020 at 21:45)</a>:</h4>
<p>duplication is hard to test because you have to somehow get the two constants into the same <code>match</code></p>



<a name="193106210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106210">(Apr 06 2020 at 21:45)</a>:</h4>
<p>yeah I figured it was something like that</p>



<a name="193106213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106213">(Apr 06 2020 at 21:45)</a>:</h4>
<p>but we have <code>mergefunc</code> now</p>



<a name="193106227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106227">(Apr 06 2020 at 21:45)</a>:</h4>
<p>so deduplication is trivial to trigger :P</p>



<a name="193106257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106257">(Apr 06 2020 at 21:45)</a>:</h4>
<p>(in fact it makes using godbolt a pain at times because identical functions are collapsed and godbolt doesn't seem to show aliases by default...)</p>



<a name="193106259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106259">(Apr 06 2020 at 21:45)</a>:</h4>
<p>on the other hand, maybe we can just go with "its an underspecified corner of the language"</p>



<a name="193106359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106359">(Apr 06 2020 at 21:46)</a>:</h4>
<p>i.e. presumably two procedures with <em>different</em> behavior would have to have different pointer values</p>



<a name="193106382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106382">(Apr 06 2020 at 21:46)</a>:</h4>
<p>the <code>match</code> behavior may be sound, assuming it doesn't get optimized weirdly, but I'd rather not <code>const</code> generics end up allowing these</p>



<a name="193106390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106390">(Apr 06 2020 at 21:46)</a>:</h4>
<p>and therefore the deduplication case is only going to fire for procedures with identical behavior</p>



<a name="193106415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106415">(Apr 06 2020 at 21:47)</a>:</h4>
<p>but yeah, I tend to agree with you: Better to force people to change their code</p>



<a name="193106418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106418">(Apr 06 2020 at 21:47)</a>:</h4>
<p>probably the best thing to do is to force <code>const</code> generics <em>types</em> to be stricter while still using the "structural match" information for user ADTs</p>



<a name="193106438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106438">(Apr 06 2020 at 21:47)</a>:</h4>
<p>if we can't change patterns themselves</p>



<a name="193106462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106462">(Apr 06 2020 at 21:47)</a>:</h4>
<p>is there already a bug filed regarding this example you just shared with me?</p>



<a name="193106473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106473">(Apr 06 2020 at 21:48)</a>:</h4>
<p>if not I'll make one; I want to make sure we keep track of this detail</p>



<a name="193106515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106515">(Apr 06 2020 at 21:48)</a>:</h4>
<p>not sure, I should've done some filing myself, idk what <span class="user-mention" data-user-id="124288">@oli</span> has done</p>



<a name="193106538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106538">(Apr 06 2020 at 21:48)</a>:</h4>
<p>its okay, I'll look into it. Thanks for exploring this.</p>



<a name="193106594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106594">(Apr 06 2020 at 21:48)</a>:</h4>
<p>(<code>const</code> generics args that aren't equivalent to a tree of integer values are impossible to represent in symbol mangling AFAIK. and also unification probably becomes a nightmare)</p>



<a name="193106678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106678">(Apr 06 2020 at 21:50)</a>:</h4>
<p>ironically raw pointers to <code>static</code>s are probably the easiest to handle since they can be described nominally without being wrong (due to them having unique address)</p>



<a name="193106752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106752">(Apr 06 2020 at 21:50)</a>:</h4>
<p>but anything else is a minefield</p>



<a name="193106822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106822">(Apr 06 2020 at 21:51)</a>:</h4>
<p>this reminds me, I need to ping the Rust v0 demangling GCC patch again, argh, nobody seems to be replying to it</p>



<a name="193106964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193106964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193106964">(Apr 06 2020 at 21:52)</a>:</h4>
<p>and at some point I should go ahead and implement full hierarchical const value mangling support (abusing the <code>const_field</code> query is probably the best way to do this heh)</p>



<a name="193116543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193116543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193116543">(Apr 06 2020 at 23:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> <span class="user-mention" data-user-id="124288">@oli</span> wait what, <code>fn recur</code> in <code>const_to_pat.rs</code> doesn't handle reference types at all?!</p>



<a name="193116607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193116607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193116607">(Apr 06 2020 at 23:44)</a>:</h4>
<p>they're not banned, so... what happens?!</p>



<a name="193116639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193116639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193116639">(Apr 06 2020 at 23:44)</a>:</h4>
<p>a <code>PatKind::Constant</code> of reference type, does it get "lazily unpacked" or something?</p>



<a name="193116779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193116779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193116779">(Apr 06 2020 at 23:46)</a>:</h4>
<p>anyway I'm happy to find <a href="https://github.com/rust-lang/rust/issues/70861#issuecomment-610093666" title="https://github.com/rust-lang/rust/issues/70861#issuecomment-610093666">https://github.com/rust-lang/rust/issues/70861#issuecomment-610093666</a></p>



<a name="193123525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123525">(Apr 07 2020 at 01:43)</a>:</h4>
<p>don't we end up calling <code>PartialEq::eq</code> for those cases?</p>



<a name="193123600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123600">(Apr 07 2020 at 01:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> that seems weird to me, references should be structural...</p>



<a name="193123612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123612">(Apr 07 2020 at 01:44)</a>:</h4>
<p>also we don't seem to call <code>PartialEq::eq</code> for non-structural ADTs, we just error</p>



<a name="193123615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123615">(Apr 07 2020 at 01:44)</a>:</h4>
<p>its certainly cases <em>like</em> that that end up calling out to the method. Maybe I'm thinking of <code>&amp;[T]</code> ...</p>



<a name="193123617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123617">(Apr 07 2020 at 01:44)</a>:</h4>
<p>it's all very obtuse to navigate</p>



<a name="193123625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123625">(Apr 07 2020 at 01:45)</a>:</h4>
<p>anyway I've opened <a href="https://github.com/rust-lang/rust/pull/70872" title="https://github.com/rust-lang/rust/pull/70872">https://github.com/rust-lang/rust/pull/70872</a></p>



<a name="193123631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123631">(Apr 07 2020 at 01:45)</a>:</h4>
<p>now I can stop thinking about this for at least two-three days :P</p>



<a name="193123632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123632">(Apr 07 2020 at 01:45)</a>:</h4>
<p>(because of crater being slow)</p>



<a name="193123695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123695">(Apr 07 2020 at 01:46)</a>:</h4>
<p>Like, this is what motivated <a href="https://github.com/rust-lang/rust/issues/62411" title="https://github.com/rust-lang/rust/issues/62411">#62411</a></p>



<a name="193123715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123715">(Apr 07 2020 at 01:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> but there's nothing that does unpacking for something like <code>&amp;(1, 2, 3)</code></p>



<a name="193123718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123718">(Apr 07 2020 at 01:47)</a>:</h4>
<p>it just stops</p>



<a name="193123722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123722">(Apr 07 2020 at 01:47)</a>:</h4>
<p>and something later sees a leaf pattern with a <code>&amp;...</code> constant in it</p>



<a name="193123767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123767">(Apr 07 2020 at 01:48)</a>:</h4>
<p>I'm not even sure how good the lint is if you add enough <code>&amp;</code>s</p>



<a name="193123774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123774">(Apr 07 2020 at 01:48)</a>:</h4>
<p>only the type check can catch anything <em>not</em> the const value check</p>



<a name="193123777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123777">(Apr 07 2020 at 01:48)</a>:</h4>
<p>maybe I'm misunderstanding your questions</p>



<a name="193123788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123788">(Apr 07 2020 at 01:48)</a>:</h4>
<p>some of the code in <code>const_to_pat</code> is in charge of the code-gen (in order to implement the desired dynamic semantics)</p>



<a name="193123791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123791">(Apr 07 2020 at 01:49)</a>:</h4>
<p>there is a hole in the Const -&gt; Pat conversion code</p>



<a name="193123794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123794">(Apr 07 2020 at 01:49)</a>:</h4>
<p>but, (unfortunately?) some of the code also in <code>const_to_pat</code> is trying to handle the static semantics (rejecting non-structural-match)</p>



<a name="193123795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123795">(Apr 07 2020 at 01:49)</a>:</h4>
<p>of the size of a large <code>&amp;</code> truck</p>



<a name="193123857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123857">(Apr 07 2020 at 01:50)</a>:</h4>
<p>I wonder if I can show the deficiencies at play here with exhaustiveness checks hmm</p>



<a name="193123879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123879">(Apr 07 2020 at 01:51)</a>:</h4>
<p>so we've been trying to add the necessary static checks. And I'm trying to understand if you are describing known deficiencies in the static check</p>



<a name="193123883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123883">(Apr 07 2020 at 01:51)</a>:</h4>
<p>(unrelatedly) wow, <a href="https://crater.rust-lang.org/ex/pr-70452" title="https://crater.rust-lang.org/ex/pr-70452">https://crater.rust-lang.org/ex/pr-70452</a> has slowed down a lot, I wonder what the rate of jobs per hour looks like (as a graph. but maybe I've seen enough graph to last me the whole year...)</p>



<a name="193123892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123892">(Apr 07 2020 at 01:51)</a>:</h4>
<p>or if you are describing deficiencies in the dynamic semantics</p>



<a name="193123900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123900">(Apr 07 2020 at 01:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> not sure, because the code is just not handling references <em>at all</em> except in the very special case of a reference to an ADT (which isn't turned into a pattern even, it just triggers an error)</p>



<a name="193123910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123910">(Apr 07 2020 at 01:51)</a>:</h4>
<p>all sorts of things can happen as a result</p>



<a name="193123958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123958">(Apr 07 2020 at 01:52)</a>:</h4>
<p>well in principle dispatching to <code>PartialEq::eq</code> is "fine" if everyone is structural-match</p>



<a name="193123963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123963">(Apr 07 2020 at 01:52)</a>:</h4>
<p>but how do we check the patterns?</p>



<a name="193123967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123967">(Apr 07 2020 at 01:52)</a>:</h4>
<p>this is the problem</p>



<a name="193123972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123972">(Apr 07 2020 at 01:53)</a>:</h4>
<p>like, fully structural patterns. there's no code in the expected place to handle references</p>



<a name="193123976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123976">(Apr 07 2020 at 01:53)</a>:</h4>
<p>so if they work they are either buggy or very limited</p>



<a name="193123979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123979">(Apr 07 2020 at 01:53)</a>:</h4>
<p>or very hacky :P</p>



<a name="193123983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123983">(Apr 07 2020 at 01:53)</a>:</h4>
<p>unfortunately I do not think I have time to have this conversation right now</p>



<a name="193123988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123988">(Apr 07 2020 at 01:53)</a>:</h4>
<p>I really do wish you could at least use words like "dynamic" and/or "static"</p>



<a name="193123991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123991">(Apr 07 2020 at 01:53)</a>:</h4>
<p>so that I could have a better idea about what you are saying is buggy</p>



<a name="193123992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193123992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193123992">(Apr 07 2020 at 01:54)</a>:</h4>
<p>I don't know which of those are affected</p>



<a name="193124050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124050">(Apr 07 2020 at 01:54)</a>:</h4>
<p>because the code isn't handling references. so it could be both or either</p>



<a name="193124056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124056">(Apr 07 2020 at 01:54)</a>:</h4>
<p>downstream code has to somehow make up for it if anything is to work</p>



<a name="193124057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124057">(Apr 07 2020 at 01:54)</a>:</h4>
<p>my belief is that these are known bugs in the desired static semantics</p>



<a name="193124080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124080">(Apr 07 2020 at 01:55)</a>:</h4>
<p>that occasional leads to ICE's that arise due to attempts to emit invocations of <code>PartialEq::eq</code> on non-existant impl's.</p>



<a name="193124088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124088">(Apr 07 2020 at 01:55)</a>:</h4>
<p>it's just broken <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=21e1b92935c02e6c6a7ed8f55620eddb" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=21e1b92935c02e6c6a7ed8f55620eddb">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=21e1b92935c02e6c6a7ed8f55620eddb</a></p>



<a name="193124093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124093">(Apr 07 2020 at 01:55)</a>:</h4>
<p>(lead to ICE's when trying to encode the dynamic semantics, that is)</p>



<a name="193124094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124094">(Apr 07 2020 at 01:55)</a>:</h4>
<p>ugh</p>



<a name="193124111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124111">(Apr 07 2020 at 01:55)</a>:</h4>
<p>the exhaustiveness checking is another kettle of fish entirelyh</p>



<a name="193124154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124154">(Apr 07 2020 at 01:56)</a>:</h4>
<p>maybe I should point out that non-structural examples don't matter, they're just blanket-caught by the type-based check</p>



<a name="193124155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124155">(Apr 07 2020 at 01:56)</a>:</h4>
<p>which I guess you did reference up above, but I did not think that was your focus here.</p>



<a name="193124159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124159">(Apr 07 2020 at 01:56)</a>:</h4>
<p>which you might be meaning by "static" checks</p>



<a name="193124168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124168">(Apr 07 2020 at 01:56)</a>:</h4>
<p>I mean, it matters maybe in terms of <em>precision</em> of diagnostics, but they'd be caught anyway</p>



<a name="193124173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124173">(Apr 07 2020 at 01:56)</a>:</h4>
<p>the problem is the code isn't <em>transparent</em> wrt references. it's like they're raw pointers</p>



<a name="193124189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124189">(Apr 07 2020 at 01:57)</a>:</h4>
<p>had you read the examples on <a href="https://github.com/rust-lang/rust/issues/62411" title="https://github.com/rust-lang/rust/issues/62411">#62411</a> ?</p>



<a name="193124194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124194">(Apr 07 2020 at 01:57)</a>:</h4>
<p>such as <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b9aeae13dc490474e1e45f294ac31e5e" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b9aeae13dc490474e1e45f294ac31e5e">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b9aeae13dc490474e1e45f294ac31e5e</a> ?</p>



<a name="193124199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124199">(Apr 07 2020 at 01:57)</a>:</h4>
<p>I'm talking about <em>structural</em> things only</p>



<a name="193124248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124248">(Apr 07 2020 at 01:58)</a>:</h4>
<p>I'm tired too, I should've been clearer from the start</p>



<a name="193124252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124252">(Apr 07 2020 at 01:58)</a>:</h4>
<p>so you're talking about cases where everything <em>does</em> implement <code>StructuralPartialEq</code> ?</p>



<a name="193124255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124255">(Apr 07 2020 at 01:58)</a>:</h4>
<p>yes</p>



<a name="193124260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124260">(Apr 07 2020 at 01:58)</a>:</h4>
<p>that was not clear to me. I was not aware of any bugs there</p>



<a name="193124263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124263">(Apr 07 2020 at 01:58)</a>:</h4>
<p>for those cases, references aren't handled the same way tuples or arrays are</p>



<a name="193124265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124265">(Apr 07 2020 at 01:58)</a>:</h4>
<p>right, but the whole point is that they don't need to be?</p>



<a name="193124272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124272">(Apr 07 2020 at 01:59)</a>:</h4>
<p>but why do tuples and arrays?</p>



<a name="193124278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124278">(Apr 07 2020 at 01:59)</a>:</h4>
<p>since dispatching to <code>PartialEq::eq</code> will work for them?</p>



<a name="193124286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124286">(Apr 07 2020 at 01:59)</a>:</h4>
<p>like, what's the difference?</p>



<a name="193124296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124296">(Apr 07 2020 at 01:59)</a>:</h4>
<p>heh, are you asking <em>why</em> the compiler has ended up in this state?</p>



<a name="193124297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124297">(Apr 07 2020 at 01:59)</a>:</h4>
<p><code>&amp;</code> is no more than a constructor in patterns</p>



<a name="193124300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124300">(Apr 07 2020 at 01:59)</a>:</h4>
<p>the unequal treatment looks <em>very</em> suspicious</p>



<a name="193124306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124306">(Apr 07 2020 at 02:00)</a>:</h4>
<p>I'm just trying to say that the observable dynamic semantics should be the same</p>



<a name="193124368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124368">(Apr 07 2020 at 02:00)</a>:</h4>
<p>for cases where the whole recursive structure is structural-match</p>



<a name="193124375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124375">(Apr 07 2020 at 02:00)</a>:</h4>
<p>so <span class="user-mention" data-user-id="124288">@oli</span> was suggesting earlier today that we should use <code>==</code> for non-structural cases</p>



<a name="193124388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124388">(Apr 07 2020 at 02:00)</a>:</h4>
<p>and for some reason I expected we're doing that already because I thought  I had seen something about <code>==</code></p>



<a name="193124404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124404">(Apr 07 2020 at 02:01)</a>:</h4>
<p>somehow I blanked out on the fact that we use <code>==</code> <em>for</em> structural cases and treat them as opaque</p>



<a name="193124405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124405">(Apr 07 2020 at 02:01)</a>:</h4>
<p>yeah years ago niko and I talked about just throwing in the towel and doing that</p>



<a name="193124411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124411">(Apr 07 2020 at 02:01)</a>:</h4>
<p>(just using <code>==</code>, that is)</p>



<a name="193124427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124427">(Apr 07 2020 at 02:01)</a>:</h4>
<p>which begs the natural question: why do this ever for <em>structural</em> cases, where you can always decompose a known value?</p>



<a name="193124429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124429">(Apr 07 2020 at 02:02)</a>:</h4>
<p>but there was a fear that this would be confusing, since manually inlining the RHS of the const-item into a pattern could then have a different semantics.</p>



<a name="193124476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124476">(Apr 07 2020 at 02:02)</a>:</h4>
<p>are you asking "why ever dispatch to <code>PartialEq::eq</code> ?</p>



<a name="193124478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124478">(Apr 07 2020 at 02:02)</a>:</h4>
<p>pretty much, I guess</p>



<a name="193124485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124485">(Apr 07 2020 at 02:02)</a>:</h4>
<p>well, you'd probably have to do some archealogy to answer that question</p>



<a name="193124488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124488">(Apr 07 2020 at 02:02)</a>:</h4>
<p>it seems unnecessary <em>unless</em> you can't evaluate the constant</p>



<a name="193124493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124493">(Apr 07 2020 at 02:03)</a>:</h4>
<p>maybe someone was worried about code size blow up</p>



<a name="193124506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124506">(Apr 07 2020 at 02:03)</a>:</h4>
<p>i.e. cheaper to store one copy of the const value in static storage and dispatch to <code>PartialEq::eq</code> rather than inline the pattern matching code for it at each pattern?</p>



<a name="193124511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124511">(Apr 07 2020 at 02:03)</a>:</h4>
<p>but now I'm just guessing</p>



<a name="193124512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124512">(Apr 07 2020 at 02:03)</a>:</h4>
<p>that feels like it should be a mode or something</p>



<a name="193124553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124553">(Apr 07 2020 at 02:04)</a>:</h4>
<p>anyway I really do have to go. I'm tired too and its not even 2am where I am.</p>



<a name="193124572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124572">(Apr 07 2020 at 02:04)</a>:</h4>
<p>or wait, 4 am? Yikes</p>



<a name="193124575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124575">(Apr 07 2020 at 02:04)</a>:</h4>
<p>where MIR matching building keeps consts opaque</p>



<a name="193124577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124577">(Apr 07 2020 at 02:04)</a>:</h4>
<p>(it's 5am here)</p>



<a name="193124582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124582">(Apr 07 2020 at 02:04)</a>:</h4>
<p>while match <em>checking</em> fully expands consts</p>



<a name="193124590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124590">(Apr 07 2020 at 02:04)</a>:</h4>
<p>the way it's setup right now <em>everyone gets the worst of both worlds</em></p>



<a name="193124676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124676">(Apr 07 2020 at 02:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> I've found so many bugs recently just by looking for places that handled Ty but not ty::Const (showing up in a type/predicate/etc.), so I guess that also makes me more suspicious than usual of asymmetries</p>



<a name="193124690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124690">(Apr 07 2020 at 02:06)</a>:</h4>
<p>but also I vaguely recall <span class="user-mention" data-user-id="124288">@oli</span> asking a question about eagerly expanding const patterns, that might be related to what I'm staring at</p>



<a name="193124722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124722">(Apr 07 2020 at 02:07)</a>:</h4>
<p>whatever, we can sort it out after the crater run. I have enough hacks in it that should gracefully handle most legitimate cases and is only slightly conservative</p>



<a name="193124769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193124769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193124769">(Apr 07 2020 at 02:08)</a>:</h4>
<p>because exhaustiveness checking doesn't seem to be able to see behind references in general, I suspect most people don't use patterns like that anyway</p>



<a name="193125128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193125128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193125128">(Apr 07 2020 at 02:16)</a>:</h4>
<p>hopefully we'll need to care less if we start using a value-based analysis on the MIR - even unevaluated consts could be considered fully structural</p>



<a name="193125142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193125142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193125142">(Apr 07 2020 at 02:16)</a>:</h4>
<p>(like an associated <code>const NONE: Option&lt;T&gt; = None;</code>)</p>



<a name="193126703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193126703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193126703">(Apr 07 2020 at 02:52)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/65466" title="https://github.com/rust-lang/rust/issues/65466">#65466</a> seems relevant to this discussion. In it, we eagerly emit a call to <code>&lt;[O&lt;B&gt;] as PartialEq&gt;::eq</code> despite the fact that <code>PartialEq</code> is not satisfied when building the MIR for <code>main</code>. This issue is somewhat orthogonal to using dataflow to check for structural match violations, since <code>O::None</code> should always be valid for structural matching.</p>
<div class="codehilite"><pre><span></span><span class="cp">#[derive(PartialEq, Eq)]</span><span class="w"></span>
<span class="k">enum</span> <span class="nc">O</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Some</span><span class="p">(</span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">T</span><span class="p">),</span><span class="w"> </span><span class="c1">// Can also use PhantomData&lt;T&gt;</span>
<span class="w">    </span><span class="nb">None</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">B</span><span class="p">;</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="n">C</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="n">O</span><span class="o">&lt;</span><span class="n">B</span><span class="o">&gt;</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">O</span>::<span class="nb">None</span><span class="p">];</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">O</span>::<span class="nb">None</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="n">x</span><span class="p">][..]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">C</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">(),</span><span class="w"></span>
<span class="w">        </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">(),</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="193126904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193126904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193126904">(Apr 07 2020 at 02:57)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/67088" title="https://github.com/rust-lang/rust/issues/67088">#67088</a>, the expr walking structural match PR, fixed this by rejecting the code entirely. This is fine as a stopgap measure, but is that what we want in the long-term? I suppose rejecting this is necessary to preserve the ability to choose between semantic and structural equality.</p>



<a name="193162871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193162871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193162871">(Apr 07 2020 at 09:52)</a>:</h4>
<p><span class="user-mention" data-user-id="118594">@ecstatic-morse</span> fascinating, so even for MIR match lowering (not sure what to call that part of MIR building tbh), we <em>must</em> descend through constants of types that <em>do not</em> implement <code>PartialEq</code></p>



<a name="193162941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193162941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193162941">(Apr 07 2020 at 09:53)</a>:</h4>
<p>and we can't just allow unevaluated generic consts on the sole basis on "const-qualif vetted them"</p>



<a name="193162966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193162966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193162966">(Apr 07 2020 at 09:53)</a>:</h4>
<p>e.g. <code>None::&lt;String&gt;</code> is fine, <code>None::&lt;Uncomparable&gt;</code> is not</p>



<a name="193163226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193163226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193163226">(Apr 07 2020 at 09:56)</a>:</h4>
<p>which is kind of sad but impossible to reconcidence without us building patterns from promotable-like MIR or something, which still limitates you compared to non-generic constants</p>



<a name="193201306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201306">(Apr 07 2020 at 15:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> good news for people using raw/fn pointers in patterns: due to <a href="https://github.com/rust-lang/rust/issues/70889" title="https://github.com/rust-lang/rust/issues/70889">#70889</a>, we might need to do a completely separate check for const generics <em>anyway</em></p>



<a name="193201398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201398">(Apr 07 2020 at 15:05)</a>:</h4>
<p>so while we could lint it or whatever, it might be as harmless as using <code>==</code> <em>shrug</em></p>



<a name="193201817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201817">(Apr 07 2020 at 15:08)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> I am not happy to keep finding aspects of Rust or parts of the compiler that break const generics in one way or another, but it's probably for the better to bite the bullet and do in-depth "constant in type" WF checks</p>



<a name="193201890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201890">(Apr 07 2020 at 15:09)</a>:</h4>
<p>ofc the usual WF-deficient culprits (type aliases and default types, AFAIK) might cause problems here, idk what to do about them</p>



<a name="193201914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201914">(Apr 07 2020 at 15:09)</a>:</h4>
<p>other than "hopefully it gets caught at use site</p>



<a name="193201966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193201966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193201966">(Apr 07 2020 at 15:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193201398" title="#narrow/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits/near/193201398">said</a>:</p>
<blockquote>
<p>so while we could lint it or whatever, it might be as harmless as using <code>==</code> <em>shrug</em></p>
</blockquote>
<p>I am not sure what "harmless" is meant to mean here.</p>



<a name="193202043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202043">(Apr 07 2020 at 15:09)</a>:</h4>
<p>it's not like the raw/<code>fn</code> pointers are <code>enum</code> discriminants</p>



<a name="193202108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202108">(Apr 07 2020 at 15:10)</a>:</h4>
<p>I don't think they can break the soundness of pattern-matching</p>



<a name="193202145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202145">(Apr 07 2020 at 15:10)</a>:</h4>
<p>they might just be surprising, that's all</p>



<a name="193202162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202162">(Apr 07 2020 at 15:10)</a>:</h4>
<p>oh, okay. Yes, to my knowledge this has never been a soundness concern</p>



<a name="193202173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202173">(Apr 07 2020 at 15:10)</a>:</h4>
<p>(same as with using <code>==</code>)</p>



<a name="193202218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202218">(Apr 07 2020 at 15:10)</a>:</h4>
<p>more a question of, as you said, violating a principle of least surprise</p>



<a name="193202298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202298">(Apr 07 2020 at 15:11)</a>:</h4>
<p>my motivation and why I was so scared was const generics, but even there I think it would just ICE or cause link errors</p>



<a name="193202317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202317">(Apr 07 2020 at 15:11)</a>:</h4>
<p>and also a dash of "we don't want to commit to structural nor semantic match by accident"</p>



<a name="193202437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202437">(Apr 07 2020 at 15:12)</a>:</h4>
<p>or like <a href="https://github.com/rust-lang/rust/issues/70889" title="https://github.com/rust-lang/rust/issues/70889">#70889</a> shows, cause two equal things to appear unequal</p>



<a name="193202454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202454">(Apr 07 2020 at 15:12)</a>:</h4>
<p>yes okay. Now I think I am grokking why you were getting so worked up about this last night.</p>



<a name="193202520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202520">(Apr 07 2020 at 15:12)</a>:</h4>
<p>I was hoping I could break pattern-matching in a way which would show why letting non-integral values in was scary but I wasn't able to</p>



<a name="193202851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193202851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193202851">(Apr 07 2020 at 15:15)</a>:</h4>
<p>and I guess from there on I was a walking talking ongoing failure to communicate</p>



<a name="193203231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193203231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193203231">(Apr 07 2020 at 15:17)</a>:</h4>
<p>welcome to my life</p>



<a name="193203510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193203510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193203510">(Apr 07 2020 at 15:18)</a>:</h4>
<p>I'm really sorry, I'm getting flashbacks of the associated type soundness bug period which lasted a year or two IIRC, and seeing similar things happening around const generics, and getting emotional about it. I really shouldn't</p>



<a name="193203853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193203853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193203853">(Apr 07 2020 at 15:20)</a>:</h4>
<p>at least const generics won't be stable any time soon so I should relax</p>



<a name="193236448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193236448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193236448">(Apr 07 2020 at 19:30)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/67343" title="https://github.com/rust-lang/rust/issues/67343">#67343</a> is ready to review. It still needs a test for cross-crate constants as match patterns, however.</p>



<a name="193237879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193237879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193237879">(Apr 07 2020 at 19:42)</a>:</h4>
<p>"auxiliary" is the keyword for multi-crate tests</p>



<a name="193238307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Structural%20match%20marker%20traits/near/193238307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Structural.20match.20marker.20traits.html#193238307">(Apr 07 2020 at 19:46)</a>:</h4>
<p>I love how simple the const-qualif impl of that is &lt;3</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>